package com.example.demo.controller;




import io.swagger.annotations.Api;

import lombok.extern.slf4j.Slf4j;

import org.springframework.web.bind.annotation.*;


/**
 * @Author: lu
 * @Date: 2024-03-26-21:15
 * @Description:
 */
@Slf4j
@RestController
@RequestMapping("/ossfs")
@Api(tags = "ossfs文件上传下载")
public class OSSController {
    //@Autowired
    //private MinioUtils minioUtils;
    //
    //@Autowired
    //private MinioConfig minioConfig;
    //
    //
    //@PostMapping("/upload")
    //@ApiOperation("上传文件")
    //public  String upload(@RequestParam("file")MultipartFile file){
    //    try {
    //        String filename = file.getOriginalFilename();
    //        String s = System.currentTimeMillis() + "-" + filename;
    //        String contentType = file.getContentType();
    //        minioUtils.uploadFile(minioConfig.getBucketName(),file,s,contentType);
    //        return "上传成功！";
    //    } catch (Exception e) {
    //        e.printStackTrace();
    //        return "上传失败";
    //    }
    //}
    //
    //@PostMapping("/uploadlast")
    //public  String upload1( MultipartFile file){
    //    String filename = file.getOriginalFilename();
    //    try {
    //        minioUtils.uploadFile(minioConfig.getBucketName(),filename,file.getInputStream());
    //    } catch (IOException e) {
    //        e.printStackTrace();
    //    }
    //    String url = minioConfig.getEndPoint() + "/" + minioConfig.getBucketName() + "/" + filename;
    //    return "上传成功！ 文件路径："+ url;
    //}
    //
    //@GetMapping("/download")
    //@ApiOperation("文件下载")
    //public Result<Boolean> download(String fileName, HttpServletResponse res, HttpServletRequest req) throws ServerException, InsufficientDataException, ErrorResponseException, IOException, NoSuchAlgorithmException, InvalidKeyException, InvalidResponseException, XmlParserException, InternalException {
    //
    //    minioUtils.download(fileName,res,req);
    //    return Result.success("下载成功");
    //}
    //
    //@PostMapping("/delete")
    //@ApiOperation("删除文件")
    //public Result<Boolean> deleteByName(String fileName){
    //    minioUtils.removeFile(minioConfig.getBucketName(),fileName);
    //    return Result.success("true");
    //}




}
